Method and apparatus for arranging pixels of picture in storage units each having storage size not divisible by pixel size

ABSTRACT

An exemplary data arrangement method for a picture includes at least the following steps: obtaining pixel data of a plurality of first N-bit pixels of the picture; and storing the obtained pixel data of the first N-bit pixels in a plurality of M-bit storage units of a first buffer based on a raster-scan order of the picture, wherein M and N are positive integers, and M is not divisible by N. Besides, at least one of the M-bit storage units is filled with part of the obtained pixel data of the first N-bit pixels, and the first N-bit pixels include at least one pixel divided into a first part stored in one of the M-bit storage units in the first buffer and a second part stored in another of the M-bit storage units in the first buffer.

CROSS REFERENCE TO RELATED APPLICATIONS

The application claims the benefit of U.S. provisional application No. 61/806,591 (filed on Mar. 29, 2013) and US. provisional application No. 61/900,633 (filed on Nov. 6, 2013), which are incorporated herein by reference.

BACKGROUND

The disclosed embodiments of the present invention relate to storing a picture in a buffer, and more particularly, to a method and apparatus for arranging pixels of a picture (e.g., a frame or a field) in storage units (e.g., memory words) each having a storage size (e.g., 128 bits) not divisible by a pixel size (e.g., 10 or 12 bits).

Because of storage and transmission limitations, there is always a desire to reduce (or compress) the pixel data amount of one picture. Since the human visual system is much more sensitive to variations in brightness than color, a video system can be optimized by devoting more bandwidth to the brightness (luma) component Y, than to the color difference (chroma) components Cb and Cr. Typically, luma pixels and chroma pixels are 8 bits per pixel in most consumer applications due to the fact that a bit depth conventionally used by many video standards is 8 bits.

In certain applications, a picture may be stored in a buffer such that the buffered picture can be used later to achieve designed functionality. For example, in a video encoder or video decoder, a reconstructed picture is stored into a frame buffer such as a dynamic random access memory (DRAM), and may be used to serve as a reference picture for motion compensation or other functions. Specifically, due to the nature of video compression and decompression, the same data structure in the frame buffer is used for writing currently decoded pixels and reading previously decoded pixels. Hence, a data arrangement of pixel data of the picture in the frame buffer may affect the efficiency of video compression and decompression.

In general, a DRAM system has a word width determined by the actual design of the DRAM system. As demand for system performance continues to increase, the DRAM word width tends to increase accordingly. For example, each data word in a DRAM which acts as a frame buffer in a video encoder or video decoder may be configured to have a 128-bit word width (i.e., a 16-byte word width). The DRAM word width M is a power-of-two value (i.e., M=2^(m)). However, it is possible that the bit depth N of luma pixels and chroma pixels in the picture is not a power-of-two value (i.e., N≠2^(n)). For example, with the development of the video standard, a larger bit depth (e.g., 10 bits or 12 bits) may be supported. If M is not divisible by N, how to adequately arrange the N-bit luma pixels and N-bit chroma pixels of the picture in the M-bit DRAM words of the frame buffer becomes an issue to be solved in the pertinent field.

SUMMARY

In accordance with exemplary embodiments of the present invention, a method and apparatus for arranging pixels of a picture (e.g., a frame or a field) in storage units (e.g., memory words) each having a storage size (e.g., 128 bits) not divisible by a pixel size (e.g., 10 or 12 bits) are proposed.

According to a first aspect of the present invention, an exemplary data arrangement method for a picture is disclosed. The exemplary data arrangement method includes: obtaining pixel data of a plurality of first N-bit pixels of the picture; and storing the obtained pixel data of the first N-bit pixels into a plurality of M-bit storage units of a first buffer based on a raster-scan order of the picture, wherein at least one of the M-bit storage units is filled with part of the obtained pixel data of the first N-bit pixels, M and N are positive integers, M is not divisible by N, and the first N-bit pixels include at least one pixel divided into a first part stored in one of the M-bit storage units in the first buffer and a second part stored in another of the M-bit storage units in the first buffer.

According to a second aspect of the present invention, another data arrangement method for a picture is disclosed. The data arrangement method includes: obtaining pixel data of a plurality of first N-bit pixels of the picture; and storing at least the obtained pixel data of the first N-bit pixels into a plurality of M-bit storage units of a first buffer based on a raster-scan order of the picture, wherein each of the M-bit storage units of the first buffer stores an integer number of first N-bit pixels without any fractional first N-bit pixel, M and N are positive integers, and M is not divisible by N.

According to a third aspect of the present invention, yet another data arrangement method for a picture is disclosed. The data arrangement method includes: obtaining pixel data of a plurality of first N-bit pixels of a picture; obtaining pixel data of a plurality of second N-bit pixels of the picture; and storing the obtained pixel data of the first N-bit pixels and the obtained pixel data of the second N-bit pixels in the M-bit storage units of a buffer based on the raster-scan order of the picture, wherein each of the M-bit storage units of the buffer stores an integer number of first N-bit pixels without any fractional first N-bit pixel, and further stores an integer number of second N-bit pixels without any fractional second N-bit pixel, the first N-bit pixels are luma pixels, the second N-bit pixels are chroma pixels, M and N are positive integers, and M is not divisible by N.

According to a fourth aspect of the present invention, an exemplary data storage apparatus is disclosed. The exemplary data storage apparatus includes a buffer and a buffer controller. The buffer has a plurality of M-bit storage units. The buffer controller is arranged to obtain pixel data of a plurality of N-bit pixels of a picture, and store the obtained pixel data of the N-bit pixels in the M-bit storage units of the buffer based on a raster-scan order of the picture, wherein at least one of the M-bit storage units is filled with part of the obtained pixel data of the N-bit pixels, M and N are positive integers, M is not divisible by N, and the N-bit pixels include at least one pixel divided into a first part stored in one of the M-bit storage units in the buffer and a second part stored in another of the M-bit storage units in the buffer.

According to a fifth aspect of the present invention, another exemplary data storage apparatus is disclosed. The exemplary data storage apparatus includes a buffer and a buffer controller. The buffer has a plurality of M-bit storage units. The buffer controller is arranged to obtain pixel data of a plurality of N-bit pixels of a picture, and store at least the obtained pixel data of the N-bit pixels in the M-bit storage units of the buffer based on a raster-scan order of the picture, wherein each of the M-bit storage units of the buffer stores an integer number of N-bit pixels without any fractional N-bit pixel, M and N are positive integers, and M is not divisible by N.

According to a sixth aspect of the present invention, yet another exemplary data storage apparatus is disclosed. The exemplary data storage apparatus includes a buffer and a buffer controller. The buffer has a plurality of M-bit storage units. The buffer controller is arranged to obtain pixel data of a plurality of first N-bit pixels of a picture, obtaining pixel data of a plurality of second N-bit pixels of the picture, and store the obtained pixel data of the first N-bit pixels and the obtained pixel data of the second N-bit pixels in the M-bit storage units of the buffer based on the raster-scan order of the picture; wherein each of the M-bit storage units of the buffer stores an integer number of first N-bit pixels without any fractional first N-bit pixel, and further stores an integer number of second N-bit pixels without any fractional second N-bit pixel, the first N-bit pixels are luma pixels, the second N-bit pixels are chroma pixels, M and N are positive integers, and M is not divisible by N.

These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating a data storage apparatus according to an embodiment of the present invention.

FIG. 2 is a diagram illustrating a data arrangement of luma pixels in one buffer according to the first exemplary data arrangement design of the present invention.

FIG. 3 is a diagram illustrating a data arrangement of chroma pixels of different chrominance components in one buffer according to the first exemplary data arrangement design of the present invention.

FIG. 4 is a diagram illustrating a data arrangement of chroma pixels of one chrominance component in one buffer and chroma pixels of another chrominance component in another buffer according to the first exemplary data arrangement design of the present invention.

FIG. 5 is a diagram illustrating a data arrangement of pixels in a buffer according to a second exemplary data arrangement design of the present invention.

FIG. 6 is a diagram illustrating a data arrangement of luma pixels in one buffer according to the third exemplary data arrangement design of the present invention.

FIG. 7 is a diagram illustrating a data arrangement of chroma pixels of different chrominance components in one buffer according to the third exemplary data arrangement design of the present invention.

FIG. 8 is a diagram illustrating a data arrangement of chroma pixels of one chrominance component in one buffer and chroma pixels of another chrominance component in another buffer according to the third exemplary data arrangement design of the present invention.

FIG. 9 is a diagram illustrating a first data arrangement of luma pixels and chroma pixels in the same buffer according to the third exemplary data arrangement design of the present invention.

FIG. 10 is a diagram illustrating a second data arrangement of luma pixels and chroma pixels in the same buffer according to the third exemplary data arrangement design of the present invention.

FIG. 11 is a diagram illustrating a third data arrangement of luma pixels and chroma pixels in the same buffer according to the third exemplary data arrangement design of the present invention.

FIG. 12 is a diagram illustrating a fourth data arrangement of luma pixels and chroma pixels in the same buffer according to the third exemplary data arrangement design of the present invention.

FIG. 13 is a flowchart illustrating a buffer write operation performed by the buffer controller 104 according to an embodiment of the present invention.

FIG. 14 is a flowchart illustrating a buffer read operation performed by the buffer controller 104 according to an embodiment of the present invention.

FIG. 15 is a diagram illustrating a data arrangement of pixels in grid units each addressed by a single address according to the third exemplary data arrangement design of the present invention.

FIG. 16 is a block diagram illustrating an application using a data storage apparatus supporting a unified addressing mode according to an embodiment of the present invention.

FIG. 17 is a flowchart illustrating a data fetch operation under a 16-bit based addressing mode according to an embodiment of the present invention.

DETAILED DESCRIPTION

Certain terms are used throughout the description and following claims to refer to particular components. As one skilled in the art will appreciate, manufacturers may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function. In the following description and in the claims, the terms “include” and “comprise” are used in an open-ended fashion, and thus should be interpreted to mean “include, but not limited to . . . ”. Also, the term “couple” is intended to mean either an indirect or direct electrical connection. Accordingly, if one device is coupled to another device, that connection may be through a direct electrical connection, or through an indirect electrical connection via other devices and connections.

FIG. 1 is a block diagram illustrating a data storage apparatus according to an embodiment of the present invention. The proposed data storage apparatus 100 may be employed in any application which needs to access a stored picture in a storage device. By way of example, but not limitation, the proposed data storage apparatus 100 may be employed in a video encoder or a video decoder, and the stored picture may be a reference picture used for motion compensation. In this embodiment, the data storage apparatus 100 includes a buffer device 101 and a buffer controller 104. The buffer device 101 may be a DRAM device configured to have one or more buffers allocated therein. For example, in one exemplary design, the buffer device 101 has one buffer 102_1 arranged to store pixel data of luma pixels corresponding to the luminance component (Y) and another buffer 1022 arranged to store pixel data of chroma pixels corresponding to different chrominance components (Cr, Cb; or U, V). In another exemplary design, the buffer device 101 has one buffer 102_1 arranged to store pixel data of luma pixels corresponding to the luminance component (Y), another buffer 102_2 arranged to store pixel data of chroma pixels corresponding to one chrominance component (Cb or U), and yet another buffer 102_3 arranged to store pixel data of chroma pixels corresponding to another chrominance component (Cr or V). In other words, the number of buffers implemented in the data storage apparatus 100 may be adjusted, depending upon actual design consideration.

The buffer controller 104 is arranged to control access (i.e., read and write) of the buffer device 101. When the buffer controller 104 receives a write request REQ_(W) for requested data, the buffer controller 104 obtains pixel data of N-bit pixels of a picture IMG_IN, and refers to the proposed data arrangement to store the obtained pixel data of N-bit pixels of the picture IMG_IN in a plurality of M-bit storage units of one buffer (e.g., 1021, 1022, or 1023) in a raster-scan order of the picture IMG_IN (i.e., a pixel-based raster-scan order from the leftmost pixel to the rightmost pixel in each pixel row of the picture IMG_IN and from the uppermost pixel row to the lowermost pixel row of the picture IMG_IN), wherein M and N are positive integers, and M is not divisible by N. In this embodiment, M is a power-of-two value (e.g., M=128 (i.e., 2⁷)), and N is not a power-of-two value (e.g., N=10 or 12). When the buffer controller 104 receives a read request REQ_(W) for requested data, the buffer controller 104 obtains stored pixel data of N-bit pixels from M-bit storage units of the buffer according to the proposed data arrangement.

It should be noted that the proposed data storage apparatus 100 may support a variety of color spaces. For example, when the picture IMG_IN entering the proposed data storage apparatus 100 is formatted in accordance with the YCbCr color space, the picture would include pixels of one luminance component (Y) and pixels of two chrominance components (Cb, Cr). For another example, when the picture IMG_IN entering the proposed data storage apparatus 100 is formatted in accordance with the YUV color space, the picture would include pixels of one luminance component (Y) and pixels of two chrominance components (U, V). For yet another example, when the picture IMG_IN entering the proposed data storage apparatus 100 is formatted in accordance with a color space other than the YUV color space and the YCbCr color space, the picture may include pixels of at least one luminance component and pixels of multiple chrominance components. To put it simply, the proposed data storage apparatus 100 is compliant with any color space having at least one luminance component and a plurality of chrominance components. For clarity and simplicity, the following assumes that the picture IMG_IN to be buffered is formatted in accordance with the YCbCr color space. However, this is for illustrative purposes only, and is not meant to be a limitation of the present invention.

In a first proposed data arrangement with raster-scan layout, at least one of the M-bit storage units is filled with part of the obtained pixel data of the N-bit pixels, and the N-bit pixels include at least one pixel divided into a first part stored in one of the M-bit storage units in the buffer and a second part stored in another of the M-bit storage units in the same buffer. It should be noted that the first proposed data arrangement with raster-scan layout may be applied to the picture IMG_IN having a 4:4:4 color format, a 4:2:2 color format, or a 4:2:0 color format. Several exemplary designs of the first proposed data arrangement with raster-scan layout are detailed as below.

Concerning a first exemplary data arrangement design, the buffer controller 104 is configured for continuously storing the obtained pixel data of the N-bit pixels in the M-bit storage units of the buffer one by one according to the raster-scan order of the picture IMG_IN, until all of the obtained pixel data are stored in the buffer. In other words, one M-bit storage unit will be filled with pixel data if pixel data of all N-bit pixels (e.g., luma pixels or chroma pixels) in the picture IMG_IN are not completely stored in the buffer yet.

Please refer to FIG. 2, which is a diagram illustrating a data arrangement of luma pixels in one buffer according to the first exemplary data arrangement design of the present invention, where at least one storage unit is filled with luma pixel data, and at least one luma pixel is divided into two parts stored in different storage units. As mentioned above, the buffer controller 104 stores luma pixels in the buffer 102_1. Each of the luma pixels in the picture IMG_IN has N bits, and each of the storage units in the buffer 102_1 has M bits. For example, N=10 and M=128 in this embodiment. Since M is not divisible by N, the size of one storage unit (e.g., a 128-bit DRAM word) is not equal to an accumulated size of an integer number of luma pixels. As shown in FIG. 2, when the number of luma pixels stored in the current storage unit 106_1 reaches int(M/N), the remaining storage space in the current storage unit 106_1 is smaller than the size of one luma pixel, where int( ) is a toward-0 integer division, i.e., an integer division with truncation of the result toward zero. For example, 9/4 is truncated to 2 by the toward-0 integer division. Specifically, supposing that the color format is 4:2:0, when 12 luma pixels P₀-P₁₁, each having 10 bits, are stored in the 128-bit storage unit 106_1, the remaining storage space in the 128-bit storage unit 106_1 only has 8 bits (i.e., M−N*int(M/N)=8). Since pixel data of luma pixels in the picture IMG_IN are continuously stored into the buffer 102_1 based on the raster-scan order of the picture IMG_IN, the next pixel P₁₂ is divided into a first part stored in the current storage unit 106_1 and a second part stored in the next storage unit 106_2, where the size of the first part is 8 bits (i.e., M−N*int(M/N)=8), and the size of the second part is 2 bits (i.e., [1+int(M/N)]*N−M=2). In this way, storage units are sequentially filled with data of luma pixels of the picture IMG_IN until all of the luma pixels are stored in the buffer 102_1.

It should be noted that, since M is not divisible by N, the M-bit storage unit would have a storage space with the size of M−N*int(M/N) for storing partial data of one or two luma pixels. More specifically, there may be three cases. In a first case, only the leftmost luma pixel in a storage unit (not shown in FIG. 2) is a divided luma pixel. In a second case, only the rightmost luma pixel in a storage unit (e.g., 106_1 in FIG. 2) is a divided luma pixel. In a third case, the leftmost pixel and the rightmost luma pixel in a storage unit (e.g., 1062 in FIG. 2) are both divided luma pixels.

Please refer to FIG. 3, which is a diagram illustrating a data arrangement of chroma pixels of different chrominance components in one buffer according to the first exemplary data arrangement design of the present invention, where at least one storage unit is filled with chroma pixel data, and at least one chroma pixel is divided into two parts stored in different storage units. As mentioned above, the buffer controller 104 stores chroma pixels corresponding to different chrominance components (Cb, Cr) in the same buffer 102_2, where chroma pixels of one chrominance component (Cb) and chroma pixels of another chrominance component (Cr) are stored in an interleaved arrangement such as Cb—Cr—Cb—Cr or Cr—Cb—Cr—Cb. Each of the chroma pixels in the picture IMG_IN has N bits, and each of the storage units in the buffer 102_2 has M bits. For example, N=10 and M=128. Since M is not divisible by N, the size of one storage unit (e.g., a 128-bit DRAM word) is not equal to an accumulated size of an integer number of chroma pixels. As shown in FIG. 3, when the number of chroma pixels stored into the current storage unit 107_1 reaches int(M/N), the remaining storage space in the current storage unit 107_1 is smaller than the size of one chroma pixel. Specifically, supposing that the color format of the picture IMG_IN is 4:2:0 and the Cb—Cr—Cb—Cr interleaved arrangement is employed, when 12 chroma pixels P_(CB,0)/P_(CR,0)/P_(CB,1)/P_(CR,1) . . . P_(CB,5), P_(CR, 5), each having 10 bits, are stored into the 128-bit storage unit 107_1, the remaining storage space in the 128-bit storage unit 107_1 only has 8 bits (i.e., M−N*int(M/N)=8). Since pixel data of chroma pixels of each chrominance component in the picture IMG_IN are continuously stored into the buffer 107_1 based on the raster-scan order of the picture IMG_IN and the Cb—Cr—Cb—Cr interleaved arrangement, the next chroma pixel P_(CB,6) is divided into a first part stored in the current storage unit 107_1 and a second part stored in the next storage unit 107_2, where the size of the first part is 8 bits (i.e., M−N*int(M/N)=8), and the size of the second part is 2 bits (i.e., [1+int(M/N)]*N−M=2). In this way, storage units are sequentially filled with data of chroma pixels of the picture IMG_IN until all of the chroma pixels are stored in the buffer 1022.

Since M is not divisible by N, the M-bit storage unit would have a storage space with the size of M−N*int(M/N) for storing partial data of one or two chroma pixels. Similarly, there may be three cases. In a first case, only the leftmost chroma pixel in a storage unit (not shown in FIG. 3) is a divided chroma pixel. In a second case, only the rightmost chroma pixel in a storage unit (e.g., 107_1 in FIG. 3) is a divided chroma pixel. In a third case, the leftmost pixel and the rightmost chroma pixel in a storage unit (e.g., 107_2) are both divided chroma pixels.

Please refer to FIG. 4, which is a diagram illustrating a data arrangement of chroma pixels of one chrominance component in one buffer and chroma pixels of another chrominance component in another buffer according to the first exemplary data arrangement design of the present invention, where at least one storage unit in each buffer is filled with chroma pixel data, and at least one chroma pixel of each chrominance component is divided into two parts stored in different storage units. As mentioned above, the buffer controller 104 stores chroma pixels corresponding to a first chrominance component (Cb) in the buffer 102_2, and stores chroma pixels corresponding to a second chrominance component (Cr) in the buffer 102_3. In other words, the buffer 102_2 is dedicated to storing chroma pixels of the first chrominance component only, and the buffer 102_3 is dedicated to storing chroma pixels of the second chrominance component only. Each of the chroma pixels in the picture IMG_IN has N bits, and each of the storage units in the buffers 102_2 and 102_3 has M bits. For example, N=10 and M=128. Since M is not divisible by N, the size of one storage unit (e.g., a 128-bit DRAM word) is not equal to an accumulated size of an integer number of chroma pixels.

As shown in FIG. 4, when the number of chroma pixels of the chrominance component Cb stored into the current storage unit 107_1 reaches int(M/N), the remaining storage space in the current storage unit 107_1 is smaller than the size of one chroma pixel of the chrominance component Cb. Specifically, supposing that the color format of the picture IMG_IN is 4:4:4, when 12 chroma pixels P_(CB,0)−P_(CB,11), each having 10 bits, are stored into the 128-bit storage unit 107_1, the remaining storage space in the 128-bit storage unit 107_1 only has 8 bits (i.e., M−N*int(M/N)=8). Since pixel data of chroma pixels of the chrominance component Cb in the picture IMG_IN are continuously stored into the buffer 102_2 based on a raster-scan order of the picture IMG_IN, the next chroma pixel P_(CB,12) is divided into a first part stored in the current storage unit 107_1 and a second part stored in the next storage unit 107_2, where the size of the first part is 8 bits (i.e., M−N*int(M/N)=8), and the size of the second part is 2 bits (i.e., [1+int(M/N)]*N−M=2). In this way, storage units are sequentially filled with data of chroma pixels of the chrominance component Cb of the picture IMG_IN, until all of the chroma pixels of the chrominance component Cb are stored in the buffer 102_2. Since M is not divisible by N, the M-bit storage unit would have a storage space with the size of M−N*int(M/N) for storing partial data of one or two chroma pixels of the chrominance component Cb. Similarly, there may be three cases. In a first case, only the leftmost chroma pixel in a storage unit (not shown in FIG. 4) is a divided chroma pixel. In a second case, only the rightmost chroma pixel in a storage unit (e.g., 107_1 in FIG. 4) is a divided chroma pixel. In a third case, the leftmost pixel and the rightmost chroma pixel in a storage unit (e.g., 107_2 in FIG. 4) are both divided chroma pixels.

When the number of chroma pixels of the other chrominance component Cr stored into the current storage unit 108_1 reaches int(M/N), the remaining storage space in the current storage unit 108_1 is smaller than the size of one chroma pixel of the chrominance component Cr. Specifically, supposing that the color format of the picture IMG_IN is 4:4:4, when 12 chroma pixels P_(CR,0)-P_(CR,11), each having 10 bits, are stored into the 128-bit storage unit 108_1, the remaining storage space in the 128-bit storage unit 108_1 only has 8 bits (i.e., M−N*int(M/N)=8). Since pixel data of chroma pixels of the chrominance component Cr in the picture IMG_IN are continuously stored into the buffer 102_3 based on the raster-scan order of the picture IMG_IN, the next chroma pixel P_(CR,12) is divided into a first part stored in the current storage unit 108_1 and a second part stored in the next storage unit 1082, where the size of the first part is 8 bits (i.e., M−N*int(M/N)=8), and the size of the second part is 2 bits (i.e., [1+int(M/N)]*N−M=2). In this way, storage units are sequentially filled with data of chroma pixels of the chrominance component Cr of the picture IMG_IN, until all of the chroma pixels of the chrominance component Cr are stored in the buffer 1023. Since M is not divisible by N, the M-bit storage unit would have a storage space with the size of M−N*int(M/N) for storing partial data of one or two chroma pixels of the chrominance component Cr. Similarly, there may be three cases. In a first case, only the leftmost chroma pixel in a storage unit (not shown in FIG. 4) is a divided chroma pixel. In a second case, only the rightmost chroma pixel in a storage unit (e.g., 108_1) is a divided chroma pixel. In a third case, the leftmost pixel and the rightmost chroma pixel in a storage unit (e.g., 108_2) are both divided chroma pixels.

Concerning each of the data arrangements based on the first exemplary data arrangement design, the buffer controller 104 is configured for continuously storing the obtained pixel data of the N-bit pixels (e.g., luma pixels, chroma pixels of different chrominance components, or chroma pixels of one chrominance component) into the M-bit storage units of a single buffer one by one according to the raster-scan order of the picture IMG_IN, until all of the obtained pixel data are stored in the buffer. In this way, the N-bit pixels would have at least one pixel divided into a first part stored in one of the M-bit storage units in the buffer and a second part stored in another of the M-bit storage units in the buffer. To put it simply, due to continuous arrangement of pixel data in storage units, the first exemplary data arrangement design would result in at least one pixel divided into two parts stored indifferent storage units. However, this is for illustrative purposes only, and is not meant to be a limitation of the present invention. Alternatively, the first exemplary data arrangement design may be modified to consider additional conditions when deciding an arrangement of each N-bit pixel in a buffer. The present invention therefore further proposes a second exemplary data arrangement design which includes the aforementioned feature of continuous arrangement of pixel data in one storage unit and an additional feature of discontinuous arrangement of pixel data in another storage unit.

Specifically, concerning the additional feature of discontinuous arrangement of pixel data in a storage unit, the second exemplary data arrangement design defines that, a leftmost N-bit pixel in each pixel row of the picture IMG_IN (e.g., a leftmost luma/chroma pixel in each luma/chroma pixel row that is accessed in a raster scan order of the picture IMG_IN) would not be a pixel divided into two parts stored in different M-bit storage units. For example, after storing pixel data of a rightmost N-bit pixel in a current pixel row of the picture IMG_IN into a current M-bit storage unit of a buffer, the buffer controller 104 stores pixel data of a leftmost N-bit pixel in a next pixel row of the picture IMG_IN into a next M-bit storage unit of the buffer no matter whether the current M-bit storage unit still has unused bit (s). Concerning any pixel which is not the leftmost pixel in a pixel row, the second exemplary data arrangement design continuously stores the pixel data into the storage unit, like the first exemplary data arrangement design. The major difference between the first exemplary data arrangement design and the second exemplary data arrangement design is that the second exemplary data arrangement design ensures that at least a portion (i.e., part or all) of the rightmost pixel in a current pixel row and at least a portion (i.e., part or all) of the leftmost pixel in a next pixel row are not stored in the same storage unit. Thus, when pixel data of the leftmost pixel in a pixel row are stored in the buffer, the stored leftmost pixel would never be across a boundary between two storage units.

Please refer to FIG. 5, which is a diagram illustrating a data arrangement of pixels in a buffer according to a second exemplary data arrangement design of the present invention, where the leftmost pixel in one pixel row would never be across a boundary between two storage units. Each of the pixels (e.g., luma pixels and chroma pixels) in the picture IMG_IN has N bits, and each of the storage units in the buffer 102_1/102_2/102_3 has M bits. For example, N=10 and M=128. Since M is not divisible by N, the size of one storage unit (e.g., a 128-bit DRAM word) is not equal to an accumulated size of an integer number of pixels. When the current pixel (e.g., luma pixel or chroma pixel) P1 is the rightmost pixel in a current pixel row, the next pixel in the raster scan order is the leftmost pixel (e.g., luma pixel or chroma pixel) P2 in the next pixel row. If the picture width is PW pixels, the bit size of each pixel row is equal to PW*N. When PW*N is divisible by M, the pixel P1 would be fully stored in one storage unit to be the last pixel (i.e., the rightmost pixel) in the storage unit, and the pixel P2 would be fully stored in another storage unit to be the first pixel (i.e., the leftmost pixel) in the another storage unit. Thus, in accordance with the first exemplary data arrangement design of the present invention (i.e., one of the data arrangements shown in FIG. 2-FIG. 4), there is no need to divide the pixel P2 into two parts stored in different storage units.

However, in accordance with the first exemplary data arrangement design of the present invention (i.e., one of the data arrangements shown in FIG. 2-FIG. 4), when PW*N is not divisible by M, the pixel P2 is divided two parts stored in different storage units if M−[(PW*N) % M]<N; and all pixel data of the pixel P2 are continuously stored into the storage unit where the pixel P1 is stored if M−[(PW*N) % M]≧N. In certain applications, it is preferred that the pixel P2 is ensured to be fully stored in a storage unit to be the first pixel (i.e., the leftmost pixel) in the storage unit. Hence, the proposed second exemplary data arrangement design may be employed to achieve this goal. When PW*N is not divisible by M, the buffer controller 104 would make one storage unit have a reserved storage space with empty bits (i.e., don't care bits) at pre-defined bit locations, where the size of the reserved storage space is equal to M−[(PW*N) % M]. As shown in FIG. 5, after the pixel data of the rightmost pixel P1 in the current pixel row are stored into the storage unit S_(N), the remaining storage space (i.e., the reserved storage space) is not used for storing pixel data. Therefore, when scanning to the next pixel row, the buffer controller 104 stores the leftmost pixel P2 to the next storage unit S_(N+1). In this way, the pixel P2 is not across a boundary of two storage units S_(N) and S_(N+1).

In the first exemplary data arrangement design (FIG. 2-FIG. 4), all of the N-bit pixels (e.g., luma pixels or chroma pixels) in the picture IMG_IN are continuously stored in M-bit storage units. In the second exemplary data arrangement design (FIG. 5), most of the N-bit pixels (e.g., luma pixels or chroma pixels) in the picture IMG_IN are continuously stored in M-bit storage units, where in one M-bit storage unit, pixel data of a rightmost pixel in a pixel row may be followed by empty bits if PW*N is not divisible by M. The present invention further proposes a third exemplary data arrangement design which ensures that each used M-bit storage unit stores an integer number of N-bit pixels without any fractional N-bit pixel. That is, each M-bit storage unit is not fully used to store pixel data bits, and has unused bits at pre-defined locations. The pre-defined locations are allowed to be distributed in an M-bit storage unit. In one exemplary design of the present invention, the unused bits are all allocated at the end of each M-bit storage unit.

In one exemplary implementation of the third exemplary data arrangement design of the present invention, the buffer controller 104 is configured for continuously storing pixel data of N-bit pixels into one M-bit storage unit of a buffer, until the M-bit storage unit does not have enough unused bits for fully storing one more N-bit pixel. Please refer to FIG. 6, which is a diagram illustrating a data arrangement of luma pixels in one buffer according to the third exemplary data arrangement design of the present invention, where each used M-bit storage unit stores an integer number of N-bit pixels without any fractional N-bit pixel. As mentioned above, the buffer controller 104 stores luma pixels in the buffer 102_1. Each of the luma pixels in the picture IMG_IN has N bits, and each of the storage units in the buffer 102_1 has M bits. For example, N=10 and M=128. Since M is not divisible by N, the size of one storage unit (e.g., a 128-bit DRAM word) is not equal to an accumulated size of an integer number of luma pixels. As shown in FIG. 6, when the number of luma pixels stored into the current storage unit 106_1 reaches int(M/N), the remaining storage space in the current storage unit 106_1 is smaller than the size of one luma pixel. Specifically, supposing that the color format of the picture IMG_IN is 4:2:0, when 12 luma pixels P₀-P₁₁, each having 10 bits, are stored into the 128-bit storage unit 106_1, the remaining storage space in the 128-bit storage unit 106_1 only has 8 bits (i.e., M−N*int(M/N)=8) which are not enough for fully storing one more 10-bit luma pixel. In this embodiment, the following unused bits of the storage unit 106_1 are left empty. In other words, the remaining storage space in the storage unit 106_1 may be regarded as having don't care bits stored therein. Since pixel data of luma pixels in the picture IMG_IN are stored in the buffer 102_1 in a raster-scan order of the picture IMG_IN and the remaining storage space in the current storage unit 106_1 is not used for storing pixel data, the buffer controller 104 therefore stores the next luma pixel P₁₂ in the raster scan order into the next storage unit 1062.

Please refer to FIG. 7, which is a diagram illustrating a data arrangement of chroma pixels of different chrominance components in one buffer according to the third exemplary data arrangement design of the present invention, where each used M-bit storage unit stores an integer number of N-bit pixels without any fractional N-bit pixel. As mentioned above, the buffer controller 104 stores chroma pixels corresponding to different chrominance components (Cb, Cr) in the same buffer 1022, where chroma pixels of one chrominance component (Cb) and chroma pixels of another chrominance component (Cr) are stored in an interleaved arrangement such as Cb—Cr—Cb—Cr or Cr—Cb—Cr—Cb. Each of the chroma pixels in the picture IMG_IN has N bits, and each of the storage units in the buffer 1022 has M bits. For example, N=10 and M=128. Since M is not divisible by N, the size of one storage unit (e.g., a 128-bit DRAM word) is not equal to an accumulated size of an integer number of chroma pixels. As shown in FIG. 7, when the number of chroma pixels stored into the current storage unit 107_1 reaches int(M/N), the remaining storage space in the current storage unit 107_1 is smaller than the size of one chroma pixel. Specifically, supposing that the color format of the picture IMG_IN is 4:2:0, when 12 chroma pixels P_(CB,0), P_(CR,0), P_(CB,1), P_(CR,1) . . . P_(CB,5), P_(CR,5)/each having 10 bits, are stored into the 128-bit storage unit 107_1, the remaining storage space in the 128-bit storage unit 107_1 only has 8 bits (i.e., M−N*int(M/N)=8) which are not enough for fully storing one more 10-bit chroma pixel. In this embodiment, the unused bits of the storage unit 107_1 are left empty. Since pixel data of chroma pixels of each chrominance component in the picture IMG_IN are stored in a raster-scan order of the picture IMG_IN and the remaining storage space of the storage unit 107_1 is not used for storing pixel data, the next chroma pixel P_(CB,6) in the raster scan order is stored in the next storage unit 107_2.

Please refer to FIG. 8, which is a diagram illustrating a data arrangement of chroma pixels of one chrominance component in one buffer and chroma pixels of another chrominance component in another buffer according to the third exemplary data arrangement design of the present invention, where each used M-bit storage unit stores an integer number of N-bit pixels without any fractional N-bit pixel. As mentioned above, the buffer controller 104 stores chroma pixels corresponding to one chrominance component (Cb) in the buffer 102_2, and stores chroma pixels corresponding to another chrominance component (Cr) in the buffer 102_3. Each of the chroma pixels in the picture IMG_IN has N bits, and each of the storage units in the buffers 102_2 and 102_3 has M bits. For example, N=10 and M=128. Since M is not divisible by N, the size of one storage unit (e.g., a 128-bit DRAM word) is not equal to an accumulated size of an integer number of chroma pixels.

As shown in FIG. 8, when the number of chroma pixels of the chrominance component Cb stored into the current storage unit 107_1 reaches int(M/N), the remaining storage space in the current storage unit 107_1 is smaller than the size of one chroma pixel of the chrominance component Cb. Specifically, supposing that the color format of the picture IMG_IN is 4:4:4, when 12 chroma pixels P_(CB,0)-P_(CB,11), each having 10 bits, are stored into the 128-bit storage unit 107_1, the remaining storage space in the 128-bit storage unit 107_1 only has 8 bits (i.e., M−N*int(M/N)=8) which are not enough for fully storing one more 10-bit chroma pixel of the chrominance component Cb. In this embodiment, the unused bits of the storage unit 107_1 are left empty. Since pixel data of chroma pixels of the chrominance component Cb are stored in a raster-scan order of the picture IMG_IN and the remaining storage space is not used for storing chroma pixel data, the next chroma pixel P_(CB,12) is stored in the next storage unit 107_2.

Similarly, as shown in FIG. 8, when the number of chroma pixels of the chrominance component Cr stored into the current storage unit 108_1 reaches int(M/N), the remaining storage space in the current storage unit 108_1 is smaller than the size of one chroma pixel of the chrominance component Cr. Specifically, supposing that the color format of the picture IMG_IN is 4:4:4, when 12 chroma pixels P_(CR,0)-P_(CR,11), each having 10 bits, are stored into the 128-bit storage unit 108_1, the remaining storage space in the 128-bit storage unit 108_1 only has 8 bits (i.e., M−N*int(M/N)=8) which are not enough for fully storing one more 10-bit chroma pixel of the chrominance component Cr. In this embodiment, the unused bits of the storage unit 108_1 are left empty. Since pixel data of chroma pixels of the chrominance component Cr are stored in a raster-scan order of the picture IMG_IN and the remaining storage space is not used for storing chroma pixel data, the next chroma pixel P_(CcR,12) is stored in the next storage unit 108_2.

In the exemplary data arrangements shown in FIG. 6-FIG. 8, the luma pixels are stored in one buffer 102_1, and the chroma pixels are stored in one buffer 102_2 (if different chrominance components are stored in the same buffer) or two buffers 102_2, 102_3 (if different chrominance components are stored in different buffers, respectively). In an alternative design, the luma pixels and the chroma pixels may be stored in the same buffer. For example, in another exemplary implementation of the third exemplary data arrangement design of the present invention (which defines that each used M-bit storage unit stores an integer number of N-bit pixels without any fractional N-bit pixel), the buffer controller 104 is configured for storing N-bit luma pixels and N-bit chroma pixels into one M-bit storage unit of a buffer (e.g., 102_1), where each of the M-bit storage units in the buffer stores an integer number of N-bit luma pixels without fractional N-bit luma pixel, and further stores an integer number of N-bit chroma pixels without fractional N-bit chroma pixel.

Please refer to FIG. 9, which is a diagram illustrating a first data arrangement of luma pixels and chroma pixels in the same buffer according to the third exemplary data arrangement design of the present invention, where each used M-bit storage unit stores an integer number of N-bit luma pixels without any fractional N-bit luma pixel, and further stores an integer number of N-bit chroma pixels without any fractional N-bit chroma pixel. Specifically, a luma-chroma interleaved data arrangement is employed for each storage unit in a buffer. As shown in FIG. 9, one M-bit storage unit is evenly divided into a plurality of grid units each having G bits. For example, M=128, N=10, and G=32. Since M is not divisible by N, the size of one storage unit (e.g., a 128-bit DRAM word) is not equal to an accumulated size of an integer number of N-bit pixels, and the size of one grid unit (e.g., one-fourth of a 128-bit DRAM word) is also not equal to an accumulated size of an integer number of N-bit pixels. Based on the luma-chroma interleaved data arrangement, each of the used G-bit grid units has at least one N-bit luma pixel and at least one N-bit chroma pixel stored therein. For example, each G-bit grid unit can store PY N-bit luma pixels and PC N-bit chroma pixels. Hence, (PY+PC)*N bits in the G-bit grid unit are used to store pixel data bits. Regarding the remaining storage space (i.e., G−(PY+PC)*N bits), it is not used to store pixel data bits, where these (G−(PY+PC)*N) unused bits are allocated in pre-defined locations of the grid unit. The pre-defined locations are allowed to be distributed in a grid unit. In one embodiment, these (G−(PY+PC)*N) unused bits are allocated at the end of each grid unit. As shown in FIG. 9, supposing that the color format of the picture IMG_IN is 4:2:0, the luma pixels P₀-P₇ are successively obtained from the picture IMG_IN in a raster-scan order of the picture IMG_IN; the chroma pixels P_(CB,0) and P_(CB,1) of one chrominance component Cb are successively obtained from the picture IMG_IN in the raster-scan order of the picture IMG_IN; and the chroma pixels P_(CR,0) and P_(CR,1) of another chrominance component Cr are successively obtained from the picture IMG_IN in the raster-scan order of the picture IMG_IN. In this embodiment, PY=2 and PC=1. Hence, two luma pixels and one chroma pixel are stored in each grid unit based on the rater-scan order of the picture IMG_IN. As shown in FIG. 9, the 1^(st) grid unit of the storage unit 106_1 stores luma pixels P₀, P₁ and chroma pixel P_(CB,0), and has the remaining storage space with 2 bits (i.e., G−(PY+PC)*N=2) left empty; the 2^(nd) grid unit of the storage unit 106_1 stores luma pixels P₂, P₃ and chroma pixel P_(CB,1), and has the remaining storage space with 2 bits left empty; the 3^(rd) grid unit of the storage unit 106_1 stores luma pixels P₄, P₅ and chroma pixel P_(CR,0), and has the remaining storage space with 2 bits left empty; and the 4^(th) grid unit of the storage unit 106_1 stores luma pixels P₆, P₇ and chroma pixel P_(CR,1), and has the remaining storage space with 2 bits left empty. If the luma-chroma interleaved data arrangement shown in FIG. 9 is employed, only one luma-chroma single buffer (e.g., 102_1) is needed in the buffer device 101.

The interleaving manner of luma pixels and chroma pixels shown in FIG. 9 is for illustrative purposes only, and is not meant to be a limitation of the present invention. Other interleaving manners of luma pixels and chroma pixels are illustrated in FIG. 10, FIG. 11 and FIG. 12, respectively.

Please refer to FIG. 10, which is a diagram illustrating a second data arrangement of luma pixels and chroma pixels in the same buffer according to the third exemplary data arrangement design of the present invention, where each used M-bit storage unit stores an integer number of N-bit luma pixels without any fractional N-bit luma pixel, and further stores an integer number of N-bit chroma pixels without any fractional N-bit chroma pixel. The luma-chroma interleaved data arrangement in FIG. 10 is similar to that in FIG. 9, and the major difference is the storage order of the chroma pixels. As shown in FIG. 10, the 1^(st) grid unit of the storage unit stores luma pixels P₀, P₁ and chroma pixel P_(CR,0), and has the remaining storage space with 2 bits (i.e., G−(PY+PC)*N=2) left empty; the 2^(nd) grid unit of the storage unit stores luma pixels P₂, P₃ and chroma pixel P_(CR,1), and has the remaining storage space with 2 bits left empty; the 3^(rd) grid unit of the storage unit stores luma pixels P₄, P₅ and chroma pixel P_(CB,0), and has the remaining storage space with 2 bits left empty; and the 4^(th) grid unit of the storage unit stores luma pixels P₆, P₇ and chroma pixel P_(CB,1), and has the remaining storage space with 2 bits left empty.

Please refer to FIG. 11, which is a diagram illustrating a third data arrangement of luma pixels and chroma pixels in the same buffer according to the third exemplary data arrangement design of the present invention, where each used M-bit storage unit stores an integer number of N-bit luma pixels without any fractional N-bit luma pixel, and further stores an integer number of N-bit chroma pixels without any fractional N-bit chroma pixel. As shown in FIG. 11, one M-bit storage unit is evenly divided into a plurality of grid units each having G bits. For example, M=128, N=10, and G=32. Besides, each G-bit grid unit can store PY N-bit luma pixels and PC N-bit chroma pixels. For example, PY=2 and PC=1. Specifically, supposing that the color format of the picture IMG_IN is 4:2:0, the luma pixels P₀-P₁₅ are successively obtained from the picture IMG_IN in a raster-scan order of the picture IMG_IN; the chroma pixels P_(CB,0)−P_(CB,3) of one chrominance component Cb are successively obtained from the picture IMG_IN in the raster-scan order of the picture IMG_IN; and the chroma pixels P_(CR,0)-P_(CR,3) of another chrominance component Cr are successively obtained from the picture IMG_IN in the raster-scan order of the picture IMG_IN. Regarding the storage unit 106_1, the 1^(st) grid unit stores luma pixels P₀, P₁ and chroma pixel P_(CB, 0), and has the remaining storage space with 2 bits left empty; the 2^(nd) grid unit stores luma pixels P₂, P₃ and chroma pixel P_(CB,1), and has the remaining storage space with 2 bits left empty; the 3^(rd) grid unit stores luma pixels P₄, P₅ and chroma pixel P_(CB,2), and has the remaining storage space with 2 bits left empty; and the 4^(th) grid unit stores luma pixels P₆, P₇ and chroma pixel P_(CB,3), and has the remaining storage space with 2 bits left empty. Regarding the next storage unit 1062, the 1^(st) grid unit stores luma pixels P₈, P₉ and chroma pixel P_(CR,0), and has the remaining storage space with 2 bits left empty; the 2^(nd) grid unit stores luma pixels P₁₀, P₁₁ and chroma pixel P_(CR,1), and has the remaining storage space with 2 bits left empty; the 3^(rd) grid unit stores luma pixels P₁₂, P₁₃ and chroma pixel P_(CR,2), and has the remaining storage space with 2 bits left empty; and the 4^(th) grid unit stores luma pixels P₁₄, P₁₅ and chroma pixel P_(CR,3), and has the remaining storage space with 2 bits left empty.

Please refer to FIG. 12, which is a diagram illustrating a fourth data arrangement of luma pixels and chroma pixels in the same buffer according to the third exemplary data arrangement design of the present invention, where each used M-bit storage unit stores an integer number of N-bit luma pixels without any fractional N-bit luma pixel, and further stores an integer number of N-bit chroma pixels without any fractional N-bit chroma pixel. The luma-chroma interleaved data arrangement in FIG. 12 is similar to that in FIG. 11, and the major difference is the storage order of the chroma pixels. As shown in FIG. 12, regarding the storage unit 106_1, the 1^(st) grid unit stores luma pixels P₀, P₁ and chroma pixel P_(CR,0), and has the remaining storage space with 2 bits left empty; the 2^(nd) grid unit stores luma pixels P₂, P₃ and chroma pixel P_(CR,1), and has the remaining storage space with 2 bits left empty; the 3^(rd) grid unit stores luma pixels P₄, P₅ and chroma pixel P_(CR,2), and has the remaining storage space with 2 bits left empty; and the 4^(th) grid unit stores luma pixels P₆, P₇ and chroma pixel P_(CR,3), and has the remaining storage space with 2 bits left empty. Regarding the next storage unit 1062, the 1^(st) grid unit stores luma pixels P₈, P₉ and chroma pixel P_(CB,0), and has the remaining storage space with 2 bits left empty; the 2^(nd) grid unit stores luma pixels P₁₀/P₁₁ and chroma pixel P_(CB,1), and has the remaining storage space with 2 bits left empty; the 3^(rd) grid unit stores luma pixels P₁₂, P₁₃ and chroma pixel P_(CB,2), and has the remaining storage space with 2 bits left empty; and the 4^(th) grid unit stores luma pixels P₁₄, P₁₅ and chroma pixel P_(CB,3), and has the remaining storage space with 2 bits left empty.

Based on the proposed data arrangement scheme, the buffer controller 104 makes pixel data of the picture IMG_IN stored in one or more buffers according to a raster-scan order of the picture IMG_IN in response to a write request REQ_(W), and reads pixel data of the picture IMG_IN from one or more buffers in response to a read request REQ_(R). For example, when the data storage apparatus 100 is implemented in a video encoder or video decoder, the write request REQ_(W) may be used to store macroblock data of a reconstructed picture, and the read request REQ_(R) may be used to read a prediction block for motion compensation.

FIG. 13 is a flowchart illustrating a buffer write operation performed by the buffer controller 104 according to an embodiment of the present invention. Provided that the result is substantially the same, the steps are not required to be executed in the exact order shown in FIG. 13. The buffer write operation may be applied to each macroblock of a picture. Since each macroblock includes pixel data of a plurality of partial pixel rows, the pixel data of the macroblock should be stored in adequate addresses of the DRAM such that pixel data of the picture are finally stored in the DRAM based on a raster-scan order of the picture and have the proposed data arrangement. The buffer write operation applied to each macroblock of the picture may be briefly summarized as below.

Step 1302: Obtain pixel data of a macroblock in a picture.

Step 1304: Calculate a corresponding DRAM start address (i.e., a base address) for storing pixel data of the macroblock.

Step 1306: Arrange the pixel data of the macroblock according to the proposed data arrangement format.

Step 1308: Store the arranged pixel data of the macroblock in the DRAM based on a raster-scan order of the picture.

In a case where the first exemplary data arrangement design (FIG. 2-FIG. 4) is employed, for each pixel in the macroblock to be stored, step 1306 will judge if the current pixel (luma pixel or chroma pixel) is across a boundary of storage units. If the current pixel (luma pixel or chroma pixel) is not across a boundary of storage units, step 1306 prepares the pixel to be fully stored in one storage unit; and if the current pixel (luma pixel or chroma pixel) is across a boundary of storage units, step 1306 breaks the pixel into two parts that will be stored into two storage units respectively.

In a case where the second exemplary data arrangement design (FIG. 5) is employed, for each pixel in the macroblock to be stored, step 1306 will judge if the current pixel (luma pixel or chroma pixel) is across a boundary of storage units. If the current pixel (luma pixel or chroma pixel) is not across a boundary of storage units, step 1306 prepares the pixel to be fully stored in one storage unit; and if the current pixel (luma pixel or chroma pixel) is across a boundary of storage units, step 1306 breaks the pixel into two parts that will be stored into two storage units respectively. Besides, when PW*N is not fully divisible by M, step 1306 further judges if the current pixel (luma pixel or chroma pixel) is the rightmost pixel in a current pixel row of the picture. If the current pixel (luma pixel or chroma pixel) is the rightmost pixel in the current pixel row of the picture, step 1306 prepares the next pixel (i.e., the leftmost pixel in a next pixel row) to be fully stored in another storage unit different from the current storage unit. If the current pixel (luma pixel or chroma pixel) is not the rightmost pixel in the current pixel row of the picture, step 1306 prepares at least a portion (i.e., part or all) of the next pixel (i.e., the leftmost pixel in a next pixel row) to be appended to an end of the current pixel in the current storage unit.

In a case where the third exemplary data arrangement design (FIG. 6-FIG. 8) is employed, step 1306 prepares P (P=int(M/N)) pixels to be fully stored in the same storage unit, and inserts (M−N*P) don't care bits at unused bit locations in the same storage unit.

FIG. 14 is a flowchart illustrating a buffer read operation performed by the buffer controller 104 according to an embodiment of the present invention. Provided that the result is substantially the same, the steps are not required to be executed in the exact order shown in FIG. 14. The buffer read operation may be applied to each prediction block needed by motion compensation. Since pixel data of the reference picture are stored in the DRAM based on a raster-scan order of the reference picture and have the proposed data arrangement, pixel data of the prediction block (which is composed of a plurality of partial pixel rows in the reference picture) should be read from adequate addresses of the DRAM. The buffer read operation applied to each prediction block of motion compensation may be briefly summarized as below.

Step 1402: Calculate a corresponding DRAM start address (i.e., a base address) for retrieving pixel data of the prediction block.

Step 1404: Calculate the block size of the prediction block.

Step 1406: Determine all DRAM addresses for storage units associated with the prediction block.

Step 1408: Fetch all needed storage units for the prediction block from the DRAM.

Step 1410: Retrieve pixel data of pixels of the prediction block from the fetched storage units according to the proposed data arrangement format.

Step 1412: Perform motion compensation for the prediction block.

In a case where the first exemplary data arrangement design (FIG. 2-FIG. 4) is employed, for each fetched storage unit obtained from the DRAM, step 1410 obtains pixel data of a plurality of pixels from the storage unit. Specifically, for each pixel in the fetched storage unit, step 1410 judges if the current pixel (luma pixel or chroma pixel) is across a boundary of storage units. If the current pixel (luma pixel or chroma pixel) is not across a boundary of storage units, step 1410 retrieves all pixel data of the pixel from the fetched storage unit; and if the current pixel (luma pixel or chroma pixel) is across a boundary of storage units, step 1410 retrieves a first part of the pixel data of the pixel from the fetched storage unit, and combines the first part of the pixel data of the pixel with a second part of the pixel data of the pixel that is obtained from a different fetched storage unit.

In a case where the second exemplary data arrangement design (FIG. 5) is employed, for each fetched storage unit obtained from the DRAM, step 1410 obtains pixel data of a plurality of pixels from the storage unit. Specifically, for each pixel in the fetched storage unit, step 1410 judges if the current pixel (luma pixel or chroma pixel) is across a boundary of storage units. If the current pixel (luma pixel or chroma pixel) is not across a boundary of storage units, step 1410 retrieves all pixel data of the pixel from the fetched storage unit; and if the current pixel (luma pixel or chroma pixel) is across a boundary of storage units, step 1410 retrieves a first part of the pixel data of the pixel from the fetched storage unit, and combines the first part of the pixel data of the pixel with a second part of the pixel data of the pixel that is obtained from a different fetched storage unit. Besides, when PW*N is not fully divisible by M, step 1410 further judges if the current pixel (luma pixel or chroma pixel) is the rightmost pixel in a pixel row of the picture. If the current pixel (luma pixel or chroma pixel) is the rightmost pixel in a pixel row of the picture, step 1410 discards empty bits (i.e., don't care bits) in unused bit locations of the fetched storage unit, and obtains pixel data of the next pixel from a different fetched storage unit. If the current pixel (luma pixel or chroma pixel) is not the rightmost pixel in a pixel row of the picture, step 1410 obtains at least a portion (i.e., part or all) of the next pixel after an end of the current pixel in the fetched storage unit.

In a case where the third exemplary data arrangement design (FIG. 6-FIG. 8) is employed, step 1410 obtains pixel data of P (P=int(M/N)) pixels in the same fetched storage unit, and discards (M−N*P) empty bits (e.g., don't care bits) in unused bit locations in the same storage unit.

Please note that the flows shown in FIG. 13 and FIG. 14 are for illustrative purposes only, and are not meant to be limitations of the present invention. That is, no matter how the pixel data of the picture are written into and read from the buffer device, any buffer device using the proposed data arrangement to store the pixel data of the picture falls within the scope of the present invention.

In above examples shown in FIG. 9-FIG. 12, one M-bit storage unit is evenly divided into a plurality of grid units each having at least one luma pixel and at least one chroma pixel stored therein. In an alternative design, one M-bit storage unit may be evenly divided into a plurality of G-bit grid units, and each of the G-bit grid units is addressed by a single address and has only one N-bit pixel (e.g., an N-bit luma pixel or an N-bit chroma pixel) stored therein. In other words, each N-bit pixel may be regarded as a G-bit pixel stored in the M-bit storage unit, where (G−N) bits in the G-bit pixel are empty bits (i.e., don't care bits). In one embodiment, these (G−N) bits are located at the end of each grid unit.

Please refer to FIG. 15, which is a diagram illustrating a data arrangement of pixels in grid units each addressed by a single address according to the third exemplary data arrangement design of the present invention, where each used M-bit storage unit stores an integer number of N-bit pixels without any fractional N-bit pixel. As shown in FIG. 15, one M-bit storage unit is evenly divided in a plurality of G-bit grid units each used for storing only one N-bit pixel. In this embodiment, M=128, G=16 and N=10. Therefore, the number of grid units in one storage unit is 8, and the grid units are addressed by memory addresses ADDR_0-ADDR_7, respectively.

Consider a case where luma pixels are stored in one buffer, and chroma pixels of different chrominance components (Cr, Cb) are stored in another buffer according to an interleaved manner. Hence, the buffer 101 is configured to have buffers 102_1 and 102_2. When the storage unit shown in FIG. 15 is one storage unit (e.g., 106_1) of the buffer 102_1, the pixels P_0−P_7 obtained from the picture IMG_IN are luma pixels, and stored in the grid units of the storage unit 106_1 in a raster-scan order of the picture IMG_IN. When the storage unit shown in FIG. 15 is one storage unit (e.g., 107_1) of the buffer 1022, the pixels P_0, P_2, P_4, P_6 obtained from the picture IMG_IN are chroma pixels of one chrominance component (e.g., Cb), and stored in the grid units of the storage unit 106_1 in a raster-scan order of the picture IMG_IN; and the pixels P_1, P_3, P_5, P_7 obtained from the picture IMG_IN are chroma pixels of another chrominance component (e.g., Cr), and stored in the grid units of the storage unit 106_1 in a raster-scan order of the picture IMG_IN.

Consider another case where luma pixels are stored in one buffer, chroma pixels of one chrominance component (e.g., Cb) are stored in another buffer, and chroma pixels of another chrominance component (e.g., Cr) are stored in yet another buffer. Hence, the buffer 101 is configured to have buffers 102_1, 102_2 and 102_3. When the storage unit shown in FIG. 15 is one storage unit (e.g., 106_1) of the buffer 102_1, the pixels P_0-P_7 obtained from the picture IMG_IN are luma pixels, and stored in the grid units of the storage unit 106_1 in a raster-scan order of the picture IMG_IN. When the storage unit shown in FIG. 15 is one storage unit (e.g., 107_1) of the buffer 102_2, the pixels P_0-P_7 obtained from the picture IMG_IN are chroma pixels of one chrominance component Cb, and stored in the grid units of the storage unit 107_1 in a raster-scan order of the picture IMG_IN. When the storage unit shown in FIG. 15 is one storage unit (e.g., 108_1) of the buffer 102_3, the pixels P_0-P_7 obtained from the picture IMG_IN are chroma pixels of another chrominance component Cr, and stored in the grid units of the storage unit 108_1 in a raster-scan order of the picture IMG_IN.

The data arrangement shown in FIG. 15 is very easy to implement, and requires lower design efforts. This is because that the size of each grid unit for storing only one N-bit pixel (N is not a power-of-two value, i.e., N≠2^(n)) may be designed to be an integer multiple of the size of a conventional 8-bit pixel (8 is a power-of-two value, i.e., 8=2³). For example, one 16-bit grid unit is capable of storing two conventional 8-bit pixels. Hence, with a slight modification made to the address generation scheme of the conventional buffer controller, a modified buffer controller can be easily obtained to realize the buffer controller 104 shown in FIG. 1.

In a preferred embodiment, the buffer controller 104 may be configured to support different pixel depths (e.g., 8 bits, 10 bits, and 12 bits) under a unified addressing mode, and each grid unit may be used to store a single pixel with one of the supported pixel depths, depending upon the application requirement. Please refer to FIG. 16, which is a block diagram illustrating an application using a data storage apparatus supporting a unified addressing mode according to an embodiment of the present invention. The data storage apparatus 100 in FIG. 16 is configured to employ the data arrangement scheme shown in FIG. 15 for storing only one N-bit pixel in each G-bit grid unit of the M-bit storage unit, where N may be 8, 10 or 12 based on the application requirement. The motion compensation circuit 1602 generates a DRAM request REQ₁ via 16-bit based address generation for reading one grid unit from the buffer device 101. Hence, the buffer controller 104 outputs one 16-bit DRAM data D_(D1) in response to the request REQ₁. The bit selector 1604 receives a mode control signal which indicates which of the supported pixel depths is actually used in the motion compensation circuit 1602, and selects/extracts at least a portion (i.e., part or all) of bits from the 16-bit DRAM data D_(D1) to generate selected data D_(s1) to the motion compensation circuit 1602.

Similarly, the display circuit 1606 generates a DRAM request REQ₂ via 16-bit based address generation for reading one grid unit from the buffer device 101. Hence, the buffer controller 104 outputs one 16-bit DRAM data D_(D2) in response to the request REQ₂. The bit selector 1608 receives a mode control signal which indicates which of the supported pixel depths is actually used in the display circuit 1606, and selects/extracts at least a portion (i.e., part or all) of bits from the 16-bit DRAM data D_(D2) to generate selected data D_(S2) to the display circuit 1606.

FIG. 17 is a flowchart illustrating a data fetch operation under a 16-bit based addressing mode according to an embodiment of the present invention. Provided that the result is substantially the same, the steps are not required to be executed in the exact order shown in FIG. 17. The data fetch operation under a 16-bit based addressing mode may be briefly summarized as below.

Step 1700: Start.

Step 1702: Fetch one storage unit.

Step 1704: Get one 16-bit grid unit inside the fetched storage unit.

Step 1706: Check a pixel depth used by a video processing circuit which requests the DRAM data. If the pixel depth is 8 bits, go to step 1708; if the pixel depth is 10 bits, go to step 1710; and if the pixel depth is 12 bits, go to step 1712.

Step 1708: Extract 8 bits from the 16-bit grid unit. Go to step 1714.

Step 1710: Extract 10 bits from the 16-bit grid unit. Go to step 1714.

Step 1712: Extract 12 bits from the 16-bit grid unit.

Step 1714: Perform a predetermined operation (e.g., motion compensation or display processing) upon the extracted bits.

Step 1716: Check if all grid units inside the fetched storage unit have been processed. If yes, go to step 1718; otherwise, go to step 1704 to get the next 16-bit grid unit inside the fetched storage unit.

Step 1718: Check if all needed DRAM data have been fetched. If yes, go to step 1720; otherwise, go to step 1702 to fetch the next storage unit.

Step 1720: End.

As a person skilled in the art can readily understand details of each step in FIG. 17 after reading above paragraphs directed to FIG. 15 and FIG. 16, further description is omitted here for brevity.

Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims. 

What is claimed is:
 1. A data arrangement method, comprising: obtaining pixel data of a plurality of first N-bit pixels of a picture; and storing the obtained pixel data of the first N-bit pixels in a plurality of M-bit storage units of a first buffer based on a raster-scan order of the picture, wherein at least one of the M-bit storage units is filled with part of the obtained pixel data of the first N-bit pixels, M and N are positive integers, M is not divisible by N, and the first N-bit pixels include at least one pixel divided into a first part stored in one of the M-bit storage units in the first buffer and a second part stored in another of the M-bit storage units in the first buffer.
 2. The data arrangement method of claim 1, wherein the storing step comprises: based on the raster-scan order of the picture, continuously storing the obtained pixel data of the first N-bit pixels in the M-bit storage units of the first buffer one by one, until all of the obtained pixel data are stored in the first buffer.
 3. The data arrangement method of claim 1, wherein the at least one pixel is not a leftmost N-bit pixel in each pixel row of the picture.
 4. The data arrangement method of claim 3, wherein the storing step comprises: after storing pixel data of a rightmost N-bit pixel in a current pixel row of the picture in a first M-bit storage unit of the first buffer, storing pixel data of a leftmost N-bit pixel in a next pixel row of the picture in a second M-bit storage unit of the first buffer no matter whether the first M-bit storage unit has unused bit(s).
 5. The data arrangement method of claim 1, wherein the first N-bit pixels are luma pixels of the picture.
 6. The data arrangement method of claim 1, wherein the first N-bit pixels are chroma pixels of different chrominance components of the picture.
 7. The data arrangement method of claim 6, wherein chroma pixels of a first chrominance component of the picture and chroma pixels of a second chrominance component of the picture are stored in an interleaved arrangement.
 8. The data arrangement method of claim 1, further comprising: obtaining pixel data of a plurality of second N-bit pixels of the picture; and storing the obtained pixel data of the second pixels in a plurality of M-bit storage units of a second buffer based on the raster-scan order of the picture; wherein the first N-bit pixels are chroma pixels of a first chrominance component of the picture, the second N-bit pixels are chroma pixels of a second chrominance component of the picture, and the second N-bit pixels include at least one pixel divided into a first part stored in one of the M-bit storage units in the second buffer and a second part stored in another of the M-bit storage units in the second buffer.
 9. The data arrangement method of claim 1, wherein the picture has a 4:4:4 color format, a 4:2:2 color format, or a 4:2:0 color format.
 10. The data arrangement method of claim 1, wherein the first buffer is a memory, and each of the M-bit storage units is one word of the memory.
 11. A data arrangement method, comprising: obtaining pixel data of a plurality of first N-bit pixels of a picture; and storing at least the obtained pixel data of the first N-bit pixels in a plurality of M-bit storage units of a first buffer based on a raster-scan order of the picture, wherein each of the M-bit storage units of the first buffer stores an integer number of first N-bit pixels without any fractional first N-bit pixel, M and N are positive integers, and M is not divisible by N.
 12. The data arrangement method of claim 11, wherein the storing step comprises: continuously storing pixel data of first N-bit pixels into one M-bit storage unit of the first buffer, until the M-bit storage unit does not have enough unused bits for fully storing one more first N-bit pixel.
 13. The data arrangement method of claim 11, wherein the first N-bit pixels are luma pixels of the picture.
 14. The data arrangement method of claim 11, wherein the first N-bit pixels are chroma pixels of different chrominance components of the picture.
 15. The data arrangement method of claim 14, wherein chroma pixels of a first chrominance component of the picture and chroma pixels of a second chrominance component of the picture are stored in an interleaved arrangement.
 16. The data arrangement method of claim 11, further comprising: obtaining pixel data of a plurality of second N-bit pixels of the picture; and storing the obtained pixel data of the second pixels in a plurality of M-bit storage units of a second buffer based on the raster-scan order of the picture; wherein each of the M-bit storage units of the second buffer stores an integer number of second N-bit pixels with any fractional second N-bit pixel, the first N-bit pixels are chroma pixels of a first chrominance component of the picture, and the second N-bit pixels are chroma pixels of a second chrominance component of the picture.
 17. The data arrangement method of claim 11, wherein each of the M-bit storage units of the first buffer is evenly divided into a plurality of grid units, and each of the grid units is addressed by a single address, and has only one first N-bit pixel stored therein.
 18. The data arrangement method of claim 11, wherein the picture has a 4:4:4 color format, a 4:2:2 color format, or a 4:2:0 color format.
 19. The data arrangement method of claim 11, wherein the first buffer is a memory, and each of the M-bit storage units is one word of the memory.
 20. A data arrangement method, comprising: obtaining pixel data of a plurality of first N-bit pixels of a picture; obtaining pixel data of a plurality of second N-bit pixels of the picture; and storing the obtained pixel data of the first N-bit pixels and the obtained pixel data of the second N-bit pixels in a plurality of M-bit storage units of a buffer based on the raster-scan order of the picture; wherein each of the M-bit storage units of the buffer stores an integer number of first N-bit pixels without any fractional first N-bit pixel, and further stores an integer number of second N-bit pixels without any fractional second N-bit pixel; the first N-bit pixels are luma pixels; the second N-bit pixels are chroma pixels; M and N are positive integers; and M is not divisible by N.
 21. The data arrangement method of claim 20, wherein each of the M-bit storage units of the buffer is evenly divided into a plurality of grid units each having at least one first N-bit pixel and at least one second N-bit pixel stored therein.
 22. A data storage apparatus, comprising: a buffer, having a plurality of M-bit storage units; and a buffer controller, arranged to obtain pixel data of a plurality of N-bit pixels of a picture, and store the obtained pixel data of the N-bit pixels in the M-bit storage units of the buffer based on a raster-scan order of the picture; wherein at least one of the M-bit storage units is filled with part of the obtained pixel data of the N-bit pixels, M and N are positive integers, M is not divisible by N, and the N-bit pixels include at least one pixel divided into a first part stored in one of the M-bit storage units in the buffer and a second part stored in another of the M-bit storage units in the buffer.
 23. A data storage apparatus, comprising: a buffer, having a plurality of M-bit storage units; and a buffer controller, arranged to obtain pixel data of a plurality of N-bit pixels of a picture, and store at least the obtained pixel data of the N-bit pixels in the M-bit storage units of the buffer based on a raster-scan order of the picture; wherein each of the M-bit storage units of the buffer stores an integer number of N-bit pixels without any fractional N-bit pixel, M and N are positive integers, and M is not divisible by N.
 24. A data storage apparatus, comprising: a buffer, having a plurality of M-bit storage units; and a buffer controller, arranged to obtain pixel data of a plurality of first N-bit pixels of a picture, obtaining pixel data of a plurality of second N-bit pixels of the picture, and store the obtained pixel data of the first N-bit pixels and the obtained pixel data of the second N-bit pixels in the M-bit storage units of the buffer based on a raster-scan order of the picture; wherein each of the M-bit storage units of the buffer stores an integer number of first N-bit pixels without any fractional first N-bit pixel, and further stores an integer number of second N-bit pixels without any fractional second N-bit pixel, the first N-bit pixels are luma pixels, the second N-bit pixels are chroma pixels, M and N are positive integers, and M is not divisible by N. 